<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>思德网</title>
<link href="${ctx.resource}/css/select2.css" rel="stylesheet" >
 <link href="${ctx.resource}/css/select2-bootstrap.css" rel="stylesheet" >
 <link rel="stylesheet"  href="${ctx.resource}/front_css/style.css" type="text/css" />
 
 <script src="${ctx.resource}/js/vendor/jquery-1.11.0.min.js"></script>
 <script src="${ctx}/static/js/select2.min.js"></script>
 <script src="${ctx}/static/js/select2_locale_zh-CN.js"></script>
 <script src="${ctx.resource}/js/vendor/bootstrap.min.js"></script>
 <script src="${ctx.resource}/js/bootstrap-modal-trigger.js"></script>

</head>
<script type="text/javascript">

  $(document).ready(function() {
	  
    $.fn.select2School = function(options)
{
    var opts = $.extend($.fn.select2School.defaults, options);
    this.select2({
        allowClear:true,
        width: 300,
        placeholder: opts.blankMsg,
        minimumInputLength:opts.minLength,
        id:function(obj){return obj[opts.valueField]},
        ajax: {
            url: opts.url,
            dataType: 'json',
            quietMillis: opts.delay ,
            data: function (term, page) {return {name: term};},
            results: function (data, page) { return {results: data};}
        },
        formatResult: function(obj){return obj[opts.textField]},
        formatSelection:function(obj){return obj[opts.textField]},
        dropdownCssClass: "bigdrop",
        escapeMarkup: function (m) { return m; }
    });
}
	$.fn.select2School.defaults = {
    blankMsg: "请输入",
    minLength: 1,
    url:'',
    initUrl:'',
    delay:1000,
    valueField:'schoolname',
    textField:'schoolname'
	}
       $('input[name="schoolname"]').select2School({
            blankMsg:'搜索学校',//这里填写空选项时显示的文字
            url:'${ctx}/school/search-school-signature',//远程加载的url
            initUrl:'${ctx}/school/search-school-signature',//初始化url
            valueField:'schoolname',//value名   在vo中对应id的属性名
            textField: 'schoolname'//显示的text
        })
        
  })
</script>
  <script type="text/javascript">
		
		
		function init() {
		//document.getElementById("signupForm").onsubmit = checkSubmit;
		}
		// 为提交按钮提供的方法
		function checkSubmit() {
				
				if( checkEmail()&checkUpwd()&checkCpwd() & checkMobile() &checkQQ()&checkName() &checkGrade()&checkSchool()) 
				{
					document.getElementById("signupForm").submit();
				}
				
		}
		
		// 密码验证
		function checkUpwd() {
			var password = document.getElementById("password");
			var passwordError = document.getElementById("passwordError");
			
			// 判断密码的格式是否正确
			if(password.value == "" || password.value == null) {
				passwordError.innerHTML = "密码不能为空";
				//upwd.focus();
				return false;
			}
			
			if(password.value.length<6){
				passwordError.innerHTML = "密码必须6位以上";
				//upwd.focus();
				return false;
			}
			
			if(/^.{6,}$/.test(password.value) == false) {
				passwordError.innerHTML = "密码是任意字符，回车除外";
				//upwd.focus();
				return false;
			}
			else{
			passwordError.innerHTML = "";
			return true;
			}
			
		}
		
		// 确认密码
		function checkCpwd() {
			var upwd = document.getElementById("password");
			var cpwd = document.getElementById("confirm_password");
			var cpwdError = document.getElementById("cpwdError");

			if(cpwd.value != upwd.value) {
				cpwdError.innerHTML = "密码不一致";
				cpwd.value = "";
				return false;
				//cpwd.focus();
			}else{
			   cpwdError.innerHTML = "";
			   return true;
			}
				
			
		}

	
		
		

		// 手机号码验证
		function checkMobile(){
			var mobile = document.getElementById("phone");			
			var mobileError = document.getElementById("mobileError");
			var pt = /^1[34587]\d{9}$/;

			if(!pt.test(mobile.value)) {
				mobileError.innerHTML = "手机号码不正确!";
				return false;
			}
				else{
				mobileError.innerHTML = "";
				  return true;
				}
				
			
		}

		function checkName() {
				var truename = document.getElementById("name");			
				var nameError = document.getElementById("nameError");
	
				if(/^[\u4e00-\u9fa5]{2,}$/.test(truename.value) == false) {
					nameError.innerHTML = "姓名必须是两位以上的中文";
					// truename.focus();
					return false;
				}else {
					nameError.innerHTML = "";
					return true;
				}
			}
		
		// Email验证
		function checkEmail(){
			var emaill = document.getElementById("email");			
			var emailError = document.getElementById("emailError");
			// aaa@aaa.com.cn 163 126.cn
			var pt = /^\w{2,}@([a-z0-9]{2,}.){1,}[a-z]{2,}$/i;
			 //var pt = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
			if(!pt.test(emaill.value)) {
				emailError.innerHTML = "Email不正确";
				return false;
			}else{
			    emailError.innerHTML = "";
				return true;
			}
		}
	    //  验证qq合法性
		function checkQQ(){
		   var qqq=document.getElementById("agent1");
		   var qqqError=document.getElementById("qqError");
		   if(isNaN(qqq.value)){
		       qqqError.innerHTML="qq只能为数字";
		       return false;
		   }
		   else{
		      qqqError.innerHTML="";
		      return true;
		   }
		}
		
		function checkSchool(){
		   var agent1=document.getElementById("agent1");
		   var schoolError=document.getElementById("schoolError");
		   if(agent1.value == "" || agent1.value == null){
		       schoolError.innerHTML=" 不能为空";
		       return false;
		   }
		   else{
		      schoolError.innerHTML="";
		      return true;
		   }
		}
		
		function checkGrade(){
		   var grade=document.getElementById("grade");
		   var gradeError=document.getElementById("gradeError");
		   if(grade.value==null||grade.value==""){
		       gradeError.innerHTML="不能为空";
		       return false;
		   }
		   else{
		      gradeError.innerHTML="";
		      return true;
		   }
		}
function alertt()
{
<%if( request.getParameter("message")!=null ){%>
	alert('<%=request.getParameter("message")%>');
<%}%>
}
		
	
  </script>


<body style=" background:#f5f5f5;" onload="alertt();">
<div class="singin">
<div class="w"><img src="${ctx.resource}/images/regest.jpg" /></div>
</div>
       <font color="red" size="5">${message}</font>
<div class="wrapper">
    <form id="signupForm" method="post" action="${ctx}/user/teacherregist" class="zcform" >
        <p class="clearfix">
        	<label class="one"  for="email"><span>*</span>注册邮箱：</label>
        	<input id="email"   name="email" class="required" value placeholder="请输入邮箱"  />
        	<font color="red">&nbsp;&nbsp;<span id="emailError" align="center" >${emailmessage }</span></font>
        </p>
        <p class="clearfix">
         	<label class="one"  for="password"><span>*</span>请设置密码：</label>
        	<input id="password"  name="password" type="password" class="{required:true,rangelength:[8,20],}" value placeholder="请输入密码 至少6位" />
            <font color="red"> <span id="passwordError" color="red">${passwordmessage }</span></font>
        </p>
        <p class="clearfix">
        	<label class="one" for="confirm_password"><span>*</span>请确认密码：</label>
        	<input id="confirm_password"  name="confirm_password" type="password" class="{required:true,equalTo:'#password'}" value placeholder="请再次输入密码" />
      		<font color="red"> <span id="cpwdError" color="red">${checkpasmessage }</span></font>
        </p>
         <p class="clearfix">
        	<label class="one" for="name"><span>*</span>姓名：</label>
        	<input id="name"   name="name" type="text" class="required" value placeholder="请输入您的姓名" />
       		<font color="red"> <span id="nameError" color="red">${namemessage }</span></font>
       
        </p>
                <p class="clearfix">
        	<span class="one"></span><span>*</span></span>学校：<input class="form-control"  type="text" value="" name="schoolname"></input>
        	<font color="red"> <span id="schoolError" color="red">${schoolmessage }</span></font>
       
        <!-- 	<input id="agent" name="schoolname" type="text" class="required" value="123"  placeholder="请输入学校名称" />  -->
        </p>
               
                <p class="clearfix">
        	<label class="one" for="grade"><span>*</span>职位：</label>
        	<input id="grade" name="position" type="text" class="required" value placeholder="请输入您目前职位" />
         <font color="red"> <span id="gradeError" color="red">${grademessage }</span></font>
       
        </p>
                
                <p class="clearfix">
        	<label class="one" for="phone"><span>*</span>手机号：</label>
        	<input id="phone"   name="cellphone" type="text" class="required" value placeholder="请输入正确的手机号" />
        	<font color="red"><span id="mobileError" color="red">${mobilemessage }</span></font>
        </p>
            <p class="clearfix">
        	<label class="one" for="agent1">QQ：</label>
        	<input id="agent1"  name="qq" type="text" class="required" value placeholder="请输入您的QQ号码" />
             <font color="red"> <span id="qqError" color="red">${passwordmessage }</span></font>
        </p>
        <p class="clearfix agreement">
        	<input type="checkbox" checked="checked" />
            <b class="left">我已阅读并同意<a href="#">《ASDAN用户注册协议》</a></b>
        </p>
       	<p class="clearfix"><input class="submit" type="button" value="立即注册" onclick="checkSubmit();"/></p>   
    </form>
    <div class="people">
<p><span><img src="${ctx.resource}/images/people01.png" /></span></p>
<p>我已注册，现在就<a href="${ctx }/sign_In.jsp">登录</a></p>
</div>
</div>



<div class="footer" >
<p><a href="#">联系我们</a>
<a href="#">意见反馈</a>
<a href="#">常见问题</a>
<a href="#">法律说明</a>
<a href="#" style=" background:none">招贤纳士</a></p>
<p>© 2011-2015   北京思德国际教育有限责任公司  版权所有  SeedChina. Co.,  京ICP备11018711号</p>
</div>
</body>
</html>















